<template>
  <div id="app">
    <el-container v-if="$route.meta.layout">
      <el-header>
        <Header></Header>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <Asider></Asider>
        </el-aside>
        <el-container>
          <el-main>
            <router-view></router-view>
          </el-main>
        </el-container>
      </el-container>
    </el-container>
    <router-view v-else />
  </div>
</template>

<script>
import Header from "./layout/header.vue";
import Footer from "./layout/footer.vue";
import Asider from "./layout/asider.vue";
import webSocket from "./utils/webSocket";
export default {
  components: { Header, Asider, Footer },
  name: "App",
    mounted() {
    // 每次刷新重新登录一遍
    window.onload = () => {
      // 判断有没有登录
      if (JSON.parse(localStorage.getItem("token"))) {
        // 登录了
        // 重新连线服务器
        webSocket.send(
          JSON.stringify({
            // type值如果为login 表示需要等路由就保存当前账户
            type: "login",
            // 发送者的名字
            uid: JSON.parse(localStorage.getItem("token")).uid
          })
        );
      } else {
        return;
      }
    };
  },
};

</script>

<style>
* {
  padding: 0;
  margin: 0;
}
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
}
*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
.el-header {
  background-color: rgb(18, 185, 171);
  color: #333;
  line-height: 60px;
  height: 60px;
}

.el-footer {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-aside {
  background-color: #545c64;
  color: #333;
  text-align: center;
  line-height: 200px;
  height: 900px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  /* text-align: center; */
  /* line-height: 160px; */
}

body > .el-container {
  margin-bottom: 40px;
}
.el-table td div {
  width: 120px;
  height: 69px;
}
.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.el-container.is-vertical{
  height: 98vh;
}
.el-aside{
  height: 660px;
}
.el-container{
  min-height: 0px;
}
</style>
